#!/bin/bash
set -ex
create_database() {
    (
    echo "CREATE DATABASE IF NOT EXISTS ${MYSQL_DATABASE-meeting} DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
    echo "GRANT SELECT, INSERT, UPDATE, DELETE ON ${MYSQL_DATABASE-meeting}.* TO '$MYSQL_USER'@'localhost' IDENTIFIED BY '$MYSQL_PASSWORD';"
    echo "FLUSH PRIVILEGES;"
    ) | mysql -uroot -p${MYSQL_ROOT_PASSWORD}
    echo "Database create finished"
}

create_database

python manage.py makemigrations
python manage.py migrate
# 启动服务
python manage.py runserver 0.0.0.0:8000